package com.hp.controller;

import com.hp.model.strategy.StrategyRequest;
import com.hp.service.strategy.ContextFacade;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;;

/**
 * @author hp
 */
@Slf4j
@RestController
@RequestMapping("/api/")
public class StrategyController {

    @Resource
    private ContextFacade contextFacade;

    @PostMapping("strategy")
    public int strategy(@Validated @RequestBody StrategyRequest strategyRequest) {

        try {
            contextFacade.doOperation(strategyRequest);
        } catch (Exception e) {
            log.error("StrategyController strategy.", e);
        }
        return 0;
    }
}
